<#include "/macro.include"/>
<#assign className = table.className>
<#assign classNameLower = className?uncap_first>
<template>
 <el-drawer title="信息编辑" :visible.sync="asyn" direction="rtl" size="65%" :destroy-on-close='true' :wrapperClosable="false" @close="closeWrapper">
        <div>
            <el-form  :inline="true" ref="${classNameLower}Form" :model="${classNameLower}Form" label-width="130px">
               <#list table.columns as column>
                  <el-form-item label="${column.columnAlias}" size='small' style="margin-left:10px">
                     <el-input v-model="${classNameLower}Form.${column.columnNameLower}" placeholder="请输入内容" clearable></el-input>
                  </el-form-item>
               </#list>
            </el-form>
        </div>
        <div style="margin-bottom: 15px;text-align: center;">
            <el-form>
                <el-row>
                    <el-col :span="24">
                        <el-form-item >
                            <el-button type="success" @click="saveFormInfo">保存</el-button>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>
     </el-drawer>
</template>

<script>
    export default {
        data() {
            return {
                asyn:true,
                ${classNameLower}Form: {
                   <#list table.columns as column>
                   ${column.columnNameLower}:'',
                   </#list>
                }
            };
        },
        props: ['father_to_son_pk'],//父组件传参
        methods: {
            closeWrapper(){
                //关闭弹窗执行的方法
                this.$emit('sonChangeFather');
            },
            saveFormInfo() {
                //保存表单信息
                var postUrl = this.${classNameLower}Form.pk != null && this.${classNameLower}Form.pk != '' && this.${classNameLower}Form.pk != undefined ? '/${classNameLower}/update' : '/${classNameLower}/save';
                this.postAxios(postUrl, this.${classNameLower}Form).then(resp => {
                    if (resp.success) {
                        this.${classNameLower}Form.pk = resp.data;
                        this.$message.success('操作成功');
                    } else {
                        this.$message.error(resp.message);
                    }
                });
            },
            initData(){
                //页面初始化方法
                if (this.father_to_son_pk != null && this.father_to_son_pk != '' && this.father_to_son_pk != undefined) {
                   this.getAxios('/${classNameLower}/query/' + this.father_to_son_pk).then(resp => {
                       if (resp.success) {
                          this.${classNameLower}Form = resp.data;
                       }
                   });
                }
            }
        },
        mounted() {
            this.initData();
        }
    };
</script>
